<?php
/**
 * Created by PhpStorm.
 * User: sunku
 * Date: 2018/1/16
 * Time: 16:35
 */

namespace Admin\Controller;
use Admin\Controller\BaseController;


class MessageController extends BaseController
{
    /**
     * 构造函数
     * ItemController constructor.
     */
    public function __construct()
    {
        //无需进行权限检测的功能
        \Org\Auth\AuthUtil::setNoAuthFuncList([
            '/admin/message/msgList'
        ]);
        parent::__construct();
    }
    public function msgList(){
        $id = I('get.id');
        $user = self::$user;
        $uid = $user['id'];
        //分页
        $page = I('get.page', 1);
        $page_size = 15;
        if(isset($id) && $id){
            D('Resource/Message','Service')->updateMessageInfo(['id'=>$id,'status'=>1]);
        }
        $params = array();
        $params['page'] = $page;
        $params['page_size'] = $page_size;
        $params['uid'] = $uid;

        $result = D('Msg', 'Logic')->searchMsgList($params);

        $page = $result['page'];
        $page_size = $result['page_size'];
        $total = $result['total'];
        $total_page = $result['total_page'];
        $msgList = $result['msgList'];
        //生成分页
        $url = "/admin/message/msgList";
        $page_html = create_page($url, $total, $page, $page_size);

        $this->assign('page', $page);
        $this->assign('page_size', $page_size);
        $this->assign('total', $total);
        $this->assign('total_page', $total_page);
        $this->assign('page_html', $page_html);

        $this->assign('uid', $uid);

        $this->assign('msgList', $msgList);

        $this->loadFrame('msgList');
    }
}